package com.lin.chapter34;

public abstract class CommandName {
    private CommandName nextOperator;

    public final String handleMessage(CommandVo vo){
        String result = "";
        if (vo.getParamList().size() == 0 || vo.getParamList().contains(this.getOperateParam())){
            return this.echo(vo);
        }else {
            result = "命令无法执行";
        }
        return result;
    }

    public void setNext(CommandName nextOperator){
        this.nextOperator = nextOperator;
    }

    protected abstract String getOperateParam();
    protected abstract String echo(CommandVo vo);
}
